
import { createStore } from 'vuex';
 
const store = createStore({
  state() {
    return {
      count: 0,
      userInfo: null,
    };
  },
  mutations: {
    increment(state) {
      state.count++;
    },
    setUserInfo(state, userInfo) {
      state.userInfo = userInfo;
    },
  },
  actions: {
    incrementAsync({ commit }) {
      setTimeout(() => {
        commit('increment');
      }, 1000);
    },
    fetchUserInfo({ commit }) {
      setTimeout(() => {
        const userInfo = { name: 'Jane Doe', age: 26 };
        commit('setUserInfo', userInfo);
      }, 1500);
    },
  },
  getters: {
    count(state) {
      return state.count;
    },
    userInfo(state) {
      return state.userInfo;
    },
  },
});
 
export default store;